package net.wanho.servlet;

import com.alibaba.fastjson.JSON;
import net.wanho.entity.Teacher;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.time.LocalDateTime;

/**
 * Author：汤小洋
 * Date：2025-06-25 15:25
 * Description：<描述>
 */
@WebServlet("/hello")
public class HelloServlet extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String address = req.getParameter("address");
        System.out.println("HelloServlet.service.............." + address);

        resp.setContentType("application/json; charset=utf8");
        PrintWriter out = resp.getWriter();

        Teacher t = new Teacher("张三", 18, "男", LocalDateTime.now());
        String jsonString = JSON.toJSONString(t);
        out.print(jsonString);
        out.close();
    }

}
